// 2025/07/27
// Author: Forever
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 500005;
struct node{
    int maxl, maxr, sum, maxall;
} tree[MAXN << 2];

int n, m, a[MAXN];

void pushup(int p){
    tree[p].maxl = max(tree[p << 1].maxl, tree[p << 1 | 1].maxl + tree[p << 1].sum);
    tree[p].maxr = max(tree[p << 1 | 1].sum + tree[p << 1].maxr, tree[p << 1 | 1].maxr);
    tree[p].sum = tree[p << 1].sum + tree[p << 1 | 1].sum;
    tree[p].maxall = max(max(tree[p << 1].maxall, tree[p << 1 | 1].maxall), tree[p << 1].maxr + tree[p << 1 | 1].maxl);
}

void build(int p, int l, int r){
    if (l == r){
        tree[p].maxl = tree[p].maxr = tree[p].sum = tree[p].maxall = a[l];
        return;
    }
    int mid = (l + r) >> 1;
    build(p << 1, l, mid);
    build(p << 1 | 1, mid + 1, r);
    pushup(p);
}

void update(int p, int l, int r, int x, int v){
    if (l == r){
        tree[p].maxl = tree[p].maxr = tree[p].sum = tree[p].maxall = v;
        return;
    }
    int mid = (l + r) >> 1;
    if (x <= mid)
        update(p << 1, l, mid, x, v);
    else
        update(p << 1 | 1, mid + 1, r, x, v);
    pushup(p);
}

node query(int p, int l, int r, int x, int y){
    if (x <= l && r <= y)
        return tree[p];
    int mid = (l + r) >> 1;
    if (y <= mid)
        return query(p << 1, l, mid, x, y);
    if (x > mid)
        return query(p << 1 | 1, mid + 1, r, x, y);
    node res, res1, res2;
    res1 = query(p << 1, l, mid, x, y);
    res2 = query(p << 1 | 1, mid + 1, r, x, y);
    res.maxl = max(res1.maxl, res2.maxl + res1.sum);
    res.maxr = max(res2.sum + res1.maxr, res2.maxr);
    res.sum = res1.sum + res2.sum;
    res.maxall = max(max(res1.maxall, res2.maxall), res1.maxr + res2.maxl);
    return res;
}


signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    build(1, 1, n);
    for (int i = 1; i <= m; i++){
        int op, x, y;
        cin >> op >> x >> y;
        if (op == 2)
            update(1, 1, n, x, y);
        else
            cout << query(1, 1, n, min(x, y), max(x, y)).maxall << endl;
    }
    return 0;
}